package com.lagou.controller;

import com.lagou.domain.Personnel;
import com.lagou.service.PersonnelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/personnel")
public class PersonnelController {

    @Autowired
    private PersonnelService personnelService;


    @RequestMapping("/findAll")
    public String findAll(Model model){

        List<Personnel> list = personnelService.findAll();

        model.addAttribute("list", list);

        return "list";
    }

    @RequestMapping("/save")
    public String save(Personnel personnel){

        personnelService.save(personnel);

        return "redirect:/personnel/findAll";
    }



}
